<template>
  <view class="container">

    <view v-if="openconsumptionItem.length !== 0" class="openrecord_box" v-for="(item,i) in openconsumptionItem"
      :key="i">
      <view class="openrecord_box_text">
        <h1>{{item.commodityName}}</h1>
        <text>{{item.createTime}}</text>
      </view>
      <view class="openrecord_box_title">
        ¥{{item.amountPaid}}
      </view>
    </view>

    <!-- 没有商品 -->
    <view class="nodetails" style="height: 510px" v-if="openconsumptionItem.length === 0">
      <view class="nodetails_img">
        <image src="http://qichong-1256206693-1256206693.cos.ap-nanjing.myqcloud.com/upload/20210617/3a7b53543eb8e61ccf6b16369db10a00.png" mode="widthFix" class="maxImage"></image>
      </view>
      <text>暂时还没有消费哦...</text>
    </view>
  </view>
</template>

<script>
  import {
    openconsumption
  } from '@/api/home.js'
  export default {
    data() {
      return {
        openconsumptionItem: []
      };
    },
    onLoad() {
      this.openconsumptionList()
    },
    methods: {
      openconsumptionList() {
        const data = {
          current: 1,
          size: 10
        }

        openconsumption(data).then(res => {
          // console.log(res)
          this.openconsumptionItem = res.data.records
        })
      }
    }
  }
</script>

<style lang="scss">
  .container {
    padding: 37.5rpx 24rpx 0;

    .openrecord_box {
      width: 702rpx;
      height: 186rpx;
      background-color: rgba(247, 247, 247, 1);
      border-radius: 20rpx;
      padding: 38rpx 50rpx;
      box-sizing: border-box;
      display: flex;
      // flex-direction: column;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 28rpx;

      .openrecord_box_text {
        height: 108rpx;
        display: flex;
        flex-direction: column;
        justify-content: space-between;

        h1 {
          font-size: 34rpx;
          color: rgba(61, 61, 61, 1);
          font-weight: bold;
        }

        text {
          color: rgba(61, 61, 61, 0.5);
          font-size: 28rpx;
        }
      }

      .openrecord_box_title {
        color: rgba(61, 61, 61, 1);
        font-size: 40rpx;
      }
    }


    .container_box {
      display: flex;
      justify-content: center;
      color: rgba(61, 61, 61, 0.5);
    }


    .nodetails {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      padding-bottom: 128rpx;

      .nodetails_img {
        .maxImage {
          width: 184rpx;
          height: 322rpx;
        }
      }

      text {
        font-size: 30rpx;
        margin-top: 20rpx;
        color: rgba(61, 61, 61, 0.3);
      }
    }
  }
</style>
